/*
 * 文件名：PushParkLot.java	 
 * 时     间：下午7:11:21
 * 作     者：Administrator       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.manager.thread;

import java.util.Date;

import com.cz073586.common.billRules.utils.DateUtil;
import com.local.entity.vo.ParkwellPayBillVo;
import com.local.model.LocalPayBill;
import com.local.service.face.ParkwellPayBillService;
import com.qianhai.common.exception.BaseException;
import com.qianhai.common.utils.Log4jUtil;
import com.qianhai.common.utils.Tools;

/**
 * 类描述:推送车位信息,车位总数减去在场车辆
 * 
 * @ClassName: PushParkLot
 * @author Administrator
 * @date 2015年9月29日 下午7:11:21
 */
public class PayBillThread implements Runnable
{
	private static Log4jUtil log = Log4jUtil.getLog4j(PayBillThread.class);
	
	private ParkwellPayBillVo parkwellPayBillVo;
	
	private ParkwellPayBillService paybillService;
	
	
	public PayBillThread(ParkwellPayBillVo parkwellPayBillVo,ParkwellPayBillService paybillService)
	{
		super();
		this.parkwellPayBillVo = parkwellPayBillVo;
		this.paybillService = paybillService;
	}



	@Override
	public void run()
	{
		
		try
		{
			LocalPayBill pb = paybillService.queryLastBill(parkwellPayBillVo.getCarInUuid());
			if (!Tools.isEmpty(pb))
			{
				pb.setCarinCreatAt(!Tools.isEmpty(parkwellPayBillVo.getCarInTime()) ? parkwellPayBillVo.getCarInTime(): new Date());
				pb.setCaroutCareteAt(!Tools.isEmpty(parkwellPayBillVo.getCarOutTime()) ? parkwellPayBillVo.getCarOutTime() : new Date());
				pb.setStayTimeLong(DateUtil.betweenTimeString(parkwellPayBillVo.getCarOutTime(),parkwellPayBillVo.getCarInTime()));
				paybillService.updateByPrimaryKeySelective(pb);
			}
		} catch (Exception e)
		{
			e.printStackTrace();
			throw new BaseException(e.getMessage());
		}
	}
}
